using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Remoting.Contexts;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Proxies;
using System.Reflection;

using Pixysoft.Reflection;


namespace Pixysoft.Framework.Security
{
    internal class SecurityInterceptorProperty : IContextProperty, IContributeObjectSink
    {
        public IMessageSink GetObjectSink(MarshalByRefObject o, IMessageSink next)
        {
            try
            {
                return new SecurityInterceptorAspect(o, next);
            }
            catch 
            {
                return next;
            }
        }

        public void Freeze(Context newContext)
        {

        }

        public bool IsNewContextOK(Context newCtx)
        {
            return true;
        }

        public string Name
        {
            get { return "SecurityInterceptorProperty"; }
        }
    }
}
